package com.vivachek.protocol.process


/**
 * @Author: YCB
 * @Time: 2022/9/26 18:46
 * @Email: congbin.yuan@vivachek.com
 * @Description: 切割协议地址,去除冗余的数据
 *
 */
internal class StripAddressProcess : AbsProcess() {

    override fun convert(data: List<Int>,origin:List<Int>) {
        if (data.isEmpty() || data.size<3){
            throw IllegalStateException("数据错误,无法剥离地址:$data")
        }
        val result = data.subList(4,data.size)
        if (result.isEmpty()){
            throw IllegalStateException("数据错误,无法确定协议命令:$data")
        }
        next?.convert(result,origin)
    }
}